In [1]:
from qutip import *
from numpy import sqrt
In [2]:
H = basis(2,0)
V = basis(2,1)
p45 = 1/sqrt(2)*(H + V)
m45 = 1/sqrt(2)*(H - V)
R = 1/sqrt(2)*(H - 1j*V)
L = 1/sqrt(2)*(H + 1j*V)
In [3]:
hh = tensor(H,H)
hv = tensor(H,V)
vh = tensor(V,H)
vv = tensor(V,V)
In [7]:
vv
Out[7]:
In [8]:
# Show these are all orthogonal:
hh.dag()*hv
Out[8]:
In [7]:
vh.dag()*hv
Out[7]:
In [9]:
qeye(2)
Out[9]:
In [20]:
# Example 8.1
Phv = H*H.dag() - V*V.dag() # polarization measurement
ps_hv = tensor(Phv,qeye(2))
pi_hv = tensor(qeye(2),Phv)
psi_hv = tensor(Phv,Phv)
print(ps_hv*tensor(V,p45) == -tensor(V,p45))
print(pi_hv*tensor(V,p45) == tensor(V,m45))
print(psi_hv*tensor(V,p45) == -tensor(V,m45))
In [23]:
# Example 8.2
Pvh = tensor(V,H)*tensor(V,H).dag()
expect(Pvh,tensor(R,p45))
Out[23]:
In [26]:
# Example 8.3
Phi = tensor(qeye(2),H)*tensor(qeye(2),H).dag()
expect(Phi,tensor(R,p45))
Out[26]:
In [27]:
# Example 8.4
state = tensor(R,p45)
expect(Pvh,state) / expect(Phi,state)
Out[27]:
In [37]:
phip = 1/sqrt(2)*(tensor(H,H) + tensor(V,V))
Phs = tensor(H,qeye(2))*tensor(H,qeye(2)).dag()
Phi = tensor(qeye(2),H)*tensor(qeye(2),H).dag()
Phshi = tensor(H,H)*tensor(H,H).dag()
expect(Phshi,phip)/ expect(Phi,phip)
Out[37]:
In [43]:
P_45s45i = tensor(p45,p45)*tensor(p45,p45).dag()
P_45i = tensor(qeye(2),p45)*tensor(qeye(2),p45).dag()
In [44]:
expect(P_45s45i,phip)/expect(P_45i,phip)
Out[44]:
In [ ]: